
<body class="iframe">
    <div class="userlist">
        <div class="frame-header">
            <h2><i class="layui-icon">&#xe705;</i>用户管理</h2>
        </div>
        <h4 class="layui-bg-dark frame-title"><i class="layui-icon">&#xe65f;</i>用户列表</h4>
        <!--			<div class="toolbox layui-form">
                                        <div class="layui-form-item">
                                                <div class="layui-inline">
                                                        <label class="layui-form-label" style="margin-top: 16px;">排序</label>
                                                        <div class="layui-input-inline" style="margin-top: 16px;">
                                                                
                                                                <select name="city" lay-verify="">
                                                                        <option value="">全部</option>
                                                                        <option value="010">今日发送量</option>
                                                                        <option value="021">累计发送量</option>
                                                                </select>
                                                        </div>
                                                </div>
                                        </div>
                                </div>-->
        <div class="data-table">
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>id</th>
                        <th>头像</th>
                        <th>用户名</th>
                        <th>邮箱</th>
                        <th>部门</th>
                        <th>等级</th>
                        <th>今日发送量</th>
                        <th>累计发送量</th>
                        <th>登录时间</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
        <div id="template-page" class="page"></div>
    </div>
</body>
<script>
    var startpage = 0, len = 10;
    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage, layer = layui.layer;
        getMemberList(startpage, len);
        laypage.render({
            elem: 'template-page'
            , count: "<?= $sumRecords ?>" //数据总数，从服务端得到
            , theme: '#01AAED'
            , limit: len
            , jump: function (obj, first) {
                page = obj.curr - 1;
                len = obj.limit;
                if (!first) {
                    startpage = page;
                    getMemberList(startpage, len);
                }
            }
        });

    });
    function getMemberList(page, limit) {
        let url = '<?= site_url("member/get_member_list") ?>';
        let jsonData = {
            'page': page,
            'limit': limit
        };
        $.get(url, jsonData, function (redata) {
            if (redata.errno == '666') {
                let str = '';
                let departmentstr='';
                for (x in redata.memberList) {
                    let num = parseInt(x) + 1;
                    let level = redata.memberList[x].level;
                    let department = redata.memberList[x].department_name;
                    if (level == 99) {
                        levelstr = '超级管理员';
                    } else if (level == 50) {
                        levelstr = '管理员';
                    } else if (level == 1) {
                        levelstr = '操作员';
                    } else {
                        levelstr = '普通用户';
                    }
                   
                    if(level == 99 &&department == null){
                        departmentstr = '网站管理员';
                    } else if(department == null) {
                        departmentstr = '个人用户';
                    } else {
                        departmentstr = department;
                    }

                    str += '<tr><td>' + num + '</td><td><img src="<?= base_url() ?>' + redata.memberList[x].photo + '"></td><td>' + redata.memberList[x].username + '</td><td>' + redata.memberList[x].email + '</td><td>' + departmentstr + '</td><td>' + levelstr + '</td><td>' + redata.memberList[x].today_usage + '</td><td>' + redata.memberList[x].total_usage+ '</td><td>' + redata.memberList[x].login_time + '</td></tr>';
                }
                $(".data-table tbody").html(str);
            } else {
                layer.msg(redata.error);
            }
        }, 'json');
    }
</script>

</html>